{
  "cells": [
    {
      "cell_type": "markdown",
      "id": "cell_0",
      "metadata": {},
      "source": [
        "# Using ContextGem's DocxConverter"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "id": "cell_1",
      "metadata": {},
      "outputs": [],
      "source": [
        "%pip install -U contextgem"
      ]
    },
    {
      "cell_type": "markdown",
      "id": "cell_2",
      "metadata": {},
      "source": [
        "To run the extraction, please provide your LLM details in the ``DocumentLLM(...)`` constructor further below."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "id": "cell_3",
      "metadata": {},
      "outputs": [],
      "source": [
        "# Using ContextGem's DocxConverter\n",
        "\n",
        "from contextgem import DocxConverter\n",
        "\n",
        "converter = DocxConverter()\n",
        "\n",
        "# Convert a DOCX file to an LLM-ready ContextGem Document\n",
        "# from path\n",
        "document = converter.convert(\"path/to/document.docx\")\n",
        "# or from file object\n",
        "with open(\"path/to/document.docx\", \"rb\") as docx_file_object:\n",
        "    document = converter.convert(docx_file_object)\n",
        "\n",
        "# You can also use it as a standalone text extractor\n",
        "docx_text = converter.convert_to_text_format(\n",
        "    \"path/to/document.docx\",\n",
        "    output_format=\"markdown\",  # or \"raw\"\n",
        ")\n"
      ]
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.10.0"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 5
}